package com.dirven.game.sprite;

public class JointSprite {

	public final static int JOINT_LOC_TOPLEFT = 0,
							JOINT_LOC_TOPCENTER = 1,
							JOINT_LOC_TOPRIGHT = 2,
							JOINT_LOC_MIDDLELEFT = 3,
							JOINT_LOC_MIDDLECENTER = 4,
							JOINT_LOC_MIDDLERIGHT = 5,
							JOINT_LOC_BOTTOMLEFT = 6,
							JOINT_LOC_BOTTOMCENTER = 7,
							JOINT_LOC_BOTTOMRIGHT = 8;
	
	public Sprite joint;
	public float xOffset,
				 yOffset;
	
	public JointSprite(Sprite joint, float xOffset, float yOffset) {
		this.joint = joint;
		this.xOffset = xOffset;
		this.yOffset = yOffset;
	}
	
	public JointSprite(Sprite joint, com.badlogic.gdx.graphics.g2d.Sprite body, int jointLocation) {
		this.joint = joint;
		
		
		switch(jointLocation) {
		
			case JOINT_LOC_TOPLEFT: 
				this.xOffset = 0;
				this.yOffset = body.getHeight();
			break;
			
			
			case JOINT_LOC_TOPCENTER: 
				this.xOffset = (body.getWidth()-joint.getWidth())/2;
				this.yOffset = body.getHeight();
			break;
			
			case JOINT_LOC_TOPRIGHT: 
				this.xOffset = body.getWidth();
				this.yOffset = body.getHeight();
			break;
			
			case JOINT_LOC_MIDDLELEFT: 
				this.xOffset = 0;
				this.yOffset = (body.getHeight() - joint.getHeight())/2;
			break;
			
			
			case JOINT_LOC_MIDDLECENTER: 
				this.xOffset = (body.getWidth()-joint.getWidth())/2;
				this.yOffset = (body.getHeight() - joint.getHeight())/2;
			break;
			
			case JOINT_LOC_MIDDLERIGHT: 
				this.xOffset = body.getWidth();
				this.yOffset = (body.getHeight() - joint.getHeight())/2;
			break;
			
			case JOINT_LOC_BOTTOMLEFT: 
				this.xOffset = 0;
				this.yOffset = 0;
			break;
			
			
			case JOINT_LOC_BOTTOMCENTER: 
				this.xOffset = (body.getWidth()-joint.getWidth())/2;
				this.yOffset = 0;
			break;
			
			case JOINT_LOC_BOTTOMRIGHT: 
				this.xOffset = body.getWidth();
				this.yOffset = 0;
			break;
		
		}
		
	}
}
